﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WanWebApplication.Common;
using WechatModule.Tool;

namespace WanWebApplication
{
    public partial class Login : System.Web.UI.Page
    {
        #region 为何不使用Cookie、localStorage等追踪状态
        //为何不使用Cookie、Session、localStorage等追踪状态
        //http://www.cnblogs.com/mmmjiang13/p/4141557.html
        //
        //以前基于cookie追踪会话的机制
        //public static WechatModule.Model.UserInfo WechatUser
        //{
        //    get
        //    {
        //        //return new WechatModule.Model.UserInfo { openid = "ofaHdtzPsUAwzxCHbyHg5NoEvZwg" };
        //        return HttpContext.Current.Session["Wechat_Login_WechatUser"] as WechatModule.Model.UserInfo;
        //    }
        //    set
        //    {
        //        HttpContext.Current.Session["Wechat_Login_WechatUser"] = value;
        //    }
        //}
        #endregion
        public int Id
        {
            get
            {
                int a = 0;
                int.TryParse(Request.QueryString["Id"], out a);
                return a;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string callbackPage = GlobalVar.WechatLoginCallbackPageUrl;
            string tempStr = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + WechatGlobalVar.AppId + "&redirect_uri=" + callbackPage + "&response_type=code&scope=snsapi_base&state=" + Id + "#wechat_redirect";
            //hid.Value = tempStr;
            a.HRef = tempStr;
        }
    }
}